home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / Moviecovers (FR).ifs < prev    next >
Text File  |  2005-05-29  |  5KB  |  153 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=Achille
  8. Title=Moviecovers
  9. Description=Importation des informations et de l'image de Moviecovers
  10. Site=http://www.moviecovers.com
  11. Language=FR
  12. Version=2.0
  13. Requires=3.5.0
  14. Comments=Un peu arrangΘ par Antoine Potten pour AMC 3.5
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19. GrandeImage=1|1|0=Prend la petite image|1=Prend la grande image
  20.  
  21. ***************************************************)
  22.  
  23. program MovieCovers;
  24.  
  25. var
  26.   MovieName: string;
  27.   LineNr: Integer;
  28.   
  29. uses
  30.   StringUtils1;
  31.  
  32. procedure AnalyzePage(Address: string);
  33. var
  34.   Line, Value: string;
  35.   LastLine, BeginPos, EndPos, TreeCount: Integer;
  36.   Page: TStringList;
  37. begin
  38.   Line := GetPage(Address);
  39.   if Pos('il n''y a pas de film correspondant à ce(s) critère(s) dans <B>MOVIECOVERS</B>', Line) > 0 then
  40.   begin
  41.     ShowMessage('Aucun film trouvΘ');
  42.     Exit;
  43.   end;
  44.   PickTreeClear;
  45.   BeginPos := Pos('<FONT size="+1" color="#000000"><B>', Line);
  46.   Delete(Line, 1, BeginPos - 1);
  47.   EndPos := Pos('</FONT>', Line);
  48.   Value := Copy(Line, 1, EndPos - 1);
  49.   HTMLRemoveTags(Value);
  50.   HTMLDecode(Value);
  51.   BeginPos := Pos(' <TABLE border=0 cellspacing=0 cellpadding=6 align="center" width="100%">', Line) + 1;
  52.   Delete(Line, 1, BeginPos);
  53.   EndPos := Pos(' <TABLE border=0 cellspacing=0 cellpadding=6 align="center" width="100%">', Line) + 1;
  54.   Delete(Line, EndPos, Length(Line));
  55.   Page := TStringList.Create;
  56.   Page.Text := Line;
  57.   Value := Trim(Value) + ' : ' + Trim(Page.GetString(2));
  58.   PickTreeAdd(Value, '');
  59.   TreeCount := 0;
  60.   for LineNr := 3 to Page.Count-1 do
  61.   begin
  62.     Line := Page.GetString(LineNr);
  63.     if Pos('<LI><A', Line) > 0 then
  64.     begin
  65.       BeginPos := Pos('/film/titre', Line);
  66.       EndPos := Pos('">', Line);
  67.       Value := 'http://www.moviecovers.com' + Copy(Line, BeginPos, EndPos - BeginPos);
  68.       HTMLRemoveTags(Line);
  69.       PickTreeAdd(Trim(Line), Value);
  70.       TreeCount := TreeCount + 1;
  71.     end;
  72.   end;
  73.   if TreeCount = 1 then
  74.     resume(Value)
  75.   else
  76.   if PickTreeExec(Address) then
  77.     resume(Address);
  78.   Page.Free;
  79. end;
  80.  
  81. function TwoLinesAfter(Pattern: string; Page: TStringList): string;
  82. begin
  83.   LineNr := FindLine(Pattern, Page, LineNr);
  84.   Result := Page.GetString(LineNr+2);
  85.   HTMLRemoveTags(Result);
  86.   HTMLDecode(Result);
  87.   Result := Trim(Result);
  88. end;
  89.  
  90. procedure resume (Adress: string);
  91. var
  92.   nouvelleadr, idcm, dure : string;
  93.   lestx: TStringList;
  94.   BeginPos, EndPos, IntValue: Integer;
  95. begin
  96.   SetField(fieldURL, Adress);
  97.   nouvelleadr:=stringreplace(Adress,'http://www.moviecovers.com/film/titre_','');
  98.   idcm:=stringreplace(nouvelleadr,'.html','');
  99.   idcm := urldecode(idcm);
  100.   Adress:='http://www.moviecovers.com/getfilm.html' ;
  101.   nouvelleadr:='idmc=' + idcm;
  102.   lestx := TStringList.Create;
  103.   lestx.text:= postpage(Adress,nouvelleadr);
  104.   Adress:=lestx.getstring(5);
  105.   SetField(fieldTranslatedTitle, lestx.getstring(0));
  106.   SetField(fieldDirector,lestx.getstring(1));
  107.   SetField(fieldYear, lestx.getstring(2));
  108.   SetField(fieldCountry, lestx.getstring(3));
  109.   SetField(fieldCategory, lestx.getstring(4));
  110.   dure:= lestx.getstring(5);
  111.   BeginPos := Pos('H', dure);
  112.   IntValue := (StrToInt(Copy(dure, 1, BeginPos - 1), 0) * 60) + (StrToInt(Copy(dure, BeginPos + 1, Length(dure)), 0));
  113.   SetField(fieldLength, IntToStr(IntValue));
  114.   SetField(fieldActors, StringReplace(lestx.getstring(6), ';', ', '));
  115.   SetField(fieldDescription, lestx.getstring(7));
  116.   SetField(fieldProducer, lestx.getstring(8));
  117.   SetField(fieldOriginalTitle, lestx.getstring(9));
  118.   if GetField(fieldOriginalTitle) = '' then
  119.       SetField(fieldOriginalTitle, GetField(fieldTranslatedTitle));
  120.   if GetOption('GrandeImage') = 1 then
  121.     GetLargePicture(idcm)
  122.   else
  123.     GetSmallPicture(idcm);
  124. end;
  125.  
  126. procedure GetLargePicture(Address: string);
  127. begin
  128.   Address := URLEncode(Address);
  129.   GetPicture('http://www.moviecovers.com/getjpg.html/' + Address);
  130. end;
  131.  
  132. procedure GetSmallPicture(Address: string);
  133. begin
  134.   Address := URLEncode(Address);
  135.   GetPicture('http://www.moviecovers.com/DATA/thumbs/films-' + LowerCase(Copy(Address, 1, 1)) + '/' + Address + '.jpg');
  136. end;
  137.  
  138. begin
  139.   if CheckVersion(3,5,0) then
  140.   begin
  141.     MovieName := GetField(fieldTranslatedTitle);
  142.     if MovieName = '' then
  143.       MovieName := GetField(fieldOriginalTitle);
  144.     if Input('MovieCovers', 'Entrez le titre du film :', MovieName) then
  145.     begin
  146.       AnalyzePage('http://www.moviecovers.com/multicrit.html?titre=' + UrlEncode(MovieName) + '&slow=1&listes=1');
  147.     end;
  148.   end else
  149.     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  150. end.program NewScript;
  151. begin
  152. end.
  153.